home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / util / cli / gengui21.lha / Gengui2.1 / Examples / jumpwin.c < prev    next >
C/C++ Source or Header  |  1995-10-04  |  4KB  |  116 lines

  1. #include <stdlib.h>
  2. #include <proto/intuition.h>
  3. #include <intuition/intuition.h>
  4. #include <proto/exec.h>
  5. #include <proto/graphics.h>
  6.  
  7. #include "jumpwin.h"
  8.  
  9. extern struct IntuitionBase *IntuitionBase;
  10. extern struct GfxBase *GfxBase;
  11. extern struct Library *GadToolsBase;
  12.  
  13. main()
  14. {
  15.    struct IntuiMessage *msg;
  16.    struct Window *win[2];
  17.    struct TextFont *font=NULL;
  18.  
  19.    int a;
  20.    int run=1;
  21.  
  22.    win[0]=OpenWindowTags(NULL,
  23.             WA_Left,0,WA_Top,20,
  24.             WA_Width,300,WA_Height,100,
  25.             WA_Title,"Window 1",
  26.             WA_IDCMP,BUTTONIDCMP|IDCMP_CLOSEWINDOW|SLIDERIDCMP|
  27.                      IDCMP_NEWSIZE|IDCMP_REFRESHWINDOW,
  28.             WA_Flags,WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET
  29.                         |WFLG_SIMPLE_REFRESH
  30.                         |WFLG_CLOSEGADGET|WFLG_ACTIVATE,
  31.             WA_MinWidth,300,WA_MinHeight,100,
  32.             WA_MaxWidth,-1,WA_MaxHeight,-1,
  33.             TAG_DONE );
  34.  
  35.    win[1]=OpenWindowTags(NULL,
  36.             WA_Left,320,WA_Top,50,
  37.             WA_Width,300,WA_Height,150,
  38.             WA_Title,"Window 2",
  39.             WA_IDCMP,BUTTONIDCMP|IDCMP_CLOSEWINDOW|SLIDERIDCMP|
  40.                      IDCMP_NEWSIZE|IDCMP_REFRESHWINDOW,
  41.             WA_Flags,WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET
  42.                         |WFLG_SIMPLE_REFRESH
  43.                         |WFLG_CLOSEGADGET|WFLG_ACTIVATE,
  44.             WA_MinWidth,300,WA_MinHeight,100,
  45.             WA_MaxWidth,-1,WA_MaxHeight,-1,
  46.             TAG_DONE );
  47.  
  48.    if(!win[0] || !win[1]) {
  49.       if(win[0]) CloseWindow(win[0]);
  50.       if(win[1]) CloseWindow(win[1]);
  51.       exit(EXIT_FAILURE);
  52.    }
  53.  
  54.    if(GG_SmartRenderGui(win[0],&JumpGui,&font)) {CloseWindow(win[0]);exit(0);}
  55.  
  56.    while(run) {
  57.       Wait((1<<win[0]->UserPort->mp_SigBit)|
  58.            (1<<win[1]->UserPort->mp_SigBit));
  59.  
  60.       for(a=0;a<2;a++) {
  61.  
  62.          if(win[a]==JumpGui.Window) {
  63.  
  64.             while(msg=GG_GetIMsg(win[a]->UserPort)) {
  65.  
  66.                switch(msg->Class) {
  67.                   case IDCMP_CLOSEWINDOW: run=0;
  68.                                           break;
  69.                   case IDCMP_NEWSIZE:     GG_ResizeGui(&JumpGui);
  70.                                           break;
  71.                   case IDCMP_REFRESHWINDOW:
  72.                                           GG_BeginRefresh(&JumpGui);
  73.                                           GG_RefreshGui(&JumpGui);
  74.                                           GG_EndRefresh(&JumpGui,TRUE);
  75.                                           break;
  76.                   case IDCMP_GADGETUP:
  77.  
  78.                         switch(GetGadget(msg)->GadgetID) {
  79.                            case WIN0:  GG_StopGui(&JumpGui);
  80.                                        GG_SmartRenderGui(win[0],&JumpGui,&font);
  81.                                        GG_ClearWindow(win[1]);
  82.                                        break;
  83.                            case WIN1:  GG_StopGui(&JumpGui);
  84.                                        GG_SmartRenderGui(win[1],&JumpGui,&font);
  85.                                        GG_ClearWindow(win[0]);
  86.                                        break;
  87.                            case OK:
  88.                            case CANCEL: run=0;
  89.                                        break;
  90.                            case FORGET:
  91.                                        GG_FreeGui(&JumpGui);
  92.                                        GG_SmartRenderGui(win[a],&JumpGui,&font);
  93.                                        break;
  94.                         }
  95.                         break;
  96.                }
  97.             }
  98.             GG_ReplyIMsg(msg);
  99.          } else {
  100.             while(msg=(void *)GetMsg(win[a]->UserPort)) ReplyMsg((void *)msg);
  101.          }
  102.  
  103.       }
  104.    }
  105.  
  106.    GG_FreeGui(&JumpGui);
  107.  
  108.    CloseWindow(win[0]);
  109.    CloseWindow(win[1]);
  110.    if(font) CloseFont(font);
  111.    return(0);
  112. }
  113.  
  114.  
  115.  
  116.